﻿using System.Collections.Generic;
using CoreEx.Common.Data;
using LinFu.IoC.Configuration;

namespace CoreEx.Common.Implementation.Data
{
    [Implements(typeof(IRow))]
    public class Row :IRow
    {
        private readonly Dictionary<string, ICell> _cells = new Dictionary<string, ICell>();

        /// <summary>
        /// Gets or sets the <see cref="ITable"/> that this row belongs to.
        /// </summary>
        public ITable Table { get; set;}


        /// <summary>
        /// Gets or sets the <see cref="ICell"/> value for the current row and column name
        /// </summary>
        /// <param name="columnName">The name of the column</param>
        /// <returns>The <see cref="ICell"/> value</returns>
        public object this[string columnName]
        {
            get
            {
                var targetCell = _cells[columnName];
                return targetCell.Value;
            }
            set
            {
                var targetCell = _cells[columnName];
                targetCell.Value = value;
            }
        }

        public IDictionary<string, ICell> Cells
        {
            get { return _cells; }
        }       
    }
}